package com.dl.study.module.user.strategy.userenum;

/**
 * @Author: user
 * @Date: 2021/11/4 14:36
 * @Description:
 */

public enum UserTypeEnum {
    Normal("1", "普通"),
    Group("2", "团队"),
    Promotion("3", "促销");

    /**
     * 代码
     */
    private String code;
    /**
     * 名称，描述
     */
    private String name;

    UserTypeEnum(String code, String name) {
        this.code = code;
        this.name = name;
    }


    public String getCode() {
        return code;
    }


    public void setCode(String code) {
        this.code = code;
    }


    public String getName() {
        return name;
    }


    public void setName(String name) {
        this.name = name;
    }


    /**
     * 根据code属性获取name属性
     *
     * @param code
     * @return
     */
    public static String getNameByCode(String code) {
        for (UserTypeEnum temp : UserTypeEnum.values()) {
            if (temp.getCode().equals(code)) {
                return temp.getName();
            }
        }
        return null;
    }

}
